1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module pango.PgFontMap; 26 27 private import glib.Str; 28 private import gobject.ObjectG; 29 private import pango.PgContext; 30 private import pango.PgFont; 31 private import pango.PgFontDescription; 32 private import pango.PgFontFamily; 33 private import pango.PgFontset; 34 private import pango.PgLanguage; 35 private import pango.c.functions; 36 public import pango.c.types; 37 38 39 /** 40 * A `PangoFontMap` represents the set of fonts available for a 41 * particular rendering system. 42 * 43 * This is a virtual object with implementations being specific to 44 * particular rendering systems. 45 */ 46 public class PgFontMap : ObjectG 47 { 48 /** the main Gtk struct */ 49 protected PangoFontMap* pangoFontMap; 50 51 /** Get the main Gtk struct */ 52 public PangoFontMap* getPgFontMapStruct(bool transferOwnership = false) 53 { 54 if (transferOwnership) 55 ownedRef = false; 56 return pangoFontMap; 57 } 58 59 /** the main Gtk struct as a void* */ 60 protected override void* getStruct() 61 { 62 return cast(void*)pangoFontMap; 63 } 64 65 /** 66 * Sets our main struct and passes it to the parent class. 67 */ 68 public this (PangoFontMap* pangoFontMap, bool ownedRef = false) 69 { 70 this.pangoFontMap = pangoFontMap; 71 super(cast(GObject*)pangoFontMap, ownedRef); 72 } 73 74 75 /** */ 76 public static GType getType() 77 { 78 return pango_font_map_get_type(); 79 } 80 81 /** 82 * Forces a change in the context, which will cause any `PangoContext` 83 * using this fontmap to change. 84 * 85 * This function is only useful when implementing a new backend 86 * for Pango, something applications won't do. Backends should 87 * call this function if they have attached extra data to the 88 * context and such data is changed. 89 * 90 * Since: 1.34 91 */ 92 public void changed() 93 { 94 pango_font_map_changed(pangoFontMap); 95 } 96 97 /** 98 * Creates a `PangoContext` connected to @fontmap. 99 * 100 * This is equivalent to [ctor@Pango.Context.new] followed by 101 * [method@Pango.Context.set_font_map]. 102 * 103 * If you are using Pango as part of a higher-level system, 104 * that system may have it's own way of create a `PangoContext`. 105 * For instance, the GTK toolkit has, among others, 106 * gtk_widget_get_pango_context(). Use those instead. 107 * 108 * Returns: the newly allocated `PangoContext`, 109 * which should be freed with g_object_unref(). 110 * 111 * Since: 1.22 112 */ 113 public PgContext createContext() 114 { 115 auto __p = pango_font_map_create_context(pangoFontMap); 116 117 if(__p is null) 118 { 119 return null; 120 } 121 122 return ObjectG.getDObject!(PgContext)(cast(PangoContext*) __p, true); 123 } 124 125 /** 126 * Gets a font family by name. 127 * 128 * Params: 129 * name = a family name 130 * 131 * Returns: the `PangoFontFamily` 132 * 133 * Since: 1.46 134 */ 135 public PgFontFamily getFamily(string name) 136 { 137 auto __p = pango_font_map_get_family(pangoFontMap, Str.toStringz(name)); 138 139 if(__p is null) 140 { 141 return null; 142 } 143 144 return ObjectG.getDObject!(PgFontFamily)(cast(PangoFontFamily*) __p); 145 } 146 147 /** 148 * Returns the current serial number of @fontmap. 149 * 150 * The serial number is initialized to an small number larger than zero 151 * when a new fontmap is created and is increased whenever the fontmap 152 * is changed. It may wrap, but will never have the value 0. Since it can 153 * wrap, never compare it with "less than", always use "not equals". 154 * 155 * The fontmap can only be changed using backend-specific API, like changing 156 * fontmap resolution. 157 * 158 * This can be used to automatically detect changes to a `PangoFontMap`, 159 * like in `PangoContext`. 160 * 161 * Returns: The current serial number of @fontmap. 162 * 163 * Since: 1.32.4 164 */ 165 public uint getSerial() 166 { 167 return pango_font_map_get_serial(pangoFontMap); 168 } 169 170 /** 171 * List all families for a fontmap. 172 * 173 * Note that the returned families are not in any particular order. 174 * 175 * `PangoFontMap` also implemented the [iface@Gio.ListModel] interface 176 * for enumerating families. 177 * 178 * Params: 179 * families = location to 180 * store a pointer to an array of `PangoFontFamily` *. 181 * This array should be freed with g_free(). 182 */ 183 public void listFamilies(out PgFontFamily[] families) 184 { 185 PangoFontFamily** outfamilies = null; 186 int nFamilies; 187 188 pango_font_map_list_families(pangoFontMap, &outfamilies, &nFamilies); 189 190 families = new PgFontFamily[nFamilies]; 191 for(size_t i = 0; i < nFamilies; i++) 192 { 193 families[i] = ObjectG.getDObject!(PgFontFamily)(cast(PangoFontFamily*) outfamilies[i]); 194 } 195 } 196 197 /** 198 * Load the font in the fontmap that is the closest match for @desc. 199 * 200 * Params: 201 * context = the `PangoContext` the font will be used with 202 * desc = a `PangoFontDescription` describing the font to load 203 * 204 * Returns: the newly allocated `PangoFont` 205 * loaded, or %NULL if no font matched. 206 */ 207 public PgFont loadFont(PgContext context, PgFontDescription desc) 208 { 209 auto __p = pango_font_map_load_font(pangoFontMap, (context is null) ? null : context.getPgContextStruct(), (desc is null) ? null : desc.getPgFontDescriptionStruct()); 210 211 if(__p is null) 212 { 213 return null; 214 } 215 216 return ObjectG.getDObject!(PgFont)(cast(PangoFont*) __p, true); 217 } 218 219 /** 220 * Load a set of fonts in the fontmap that can be used to render 221 * a font matching @desc. 222 * 223 * Params: 224 * context = the `PangoContext` the font will be used with 225 * desc = a `PangoFontDescription` describing the font to load 226 * language = a `PangoLanguage` the fonts will be used for 227 * 228 * Returns: the newly allocated 229 * `PangoFontset` loaded, or %NULL if no font matched. 230 */ 231 public PgFontset loadFontset(PgContext context, PgFontDescription desc, PgLanguage language) 232 { 233 auto __p = pango_font_map_load_fontset(pangoFontMap, (context is null) ? null : context.getPgContextStruct(), (desc is null) ? null : desc.getPgFontDescriptionStruct(), (language is null) ? null : language.getPgLanguageStruct()); 234 235 if(__p is null) 236 { 237 return null; 238 } 239 240 return ObjectG.getDObject!(PgFontset)(cast(PangoFontset*) __p, true); 241 } 242 }